//token
//引入jwt插件
var jwt = require('jsonwebtoken');
var secret = 'pearGarden';

//生成token
exports.createToken = function(e){
	let payload = {id:e,time:new Date()};
	let token = jwt.sign(payload,secret);
	
	return token
}

//解吗token
exports.verifyToken = function(e){
	let payload;
	jwt.verify(e,secret,function(err,result){
		if(err){
			payload = 1
		}else{
			payload = 0
		}
	});
	
	return payload
}